package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ActivityManagement;
import com.ruoyi.system.domain.ActivitySummary;
import com.ruoyi.system.service.IActivitySummaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 活动纪要Controller
 *
 * @author ruoyi
 * @date 2024-04-03
 */
@RestController
@RequestMapping("/system/activity/summary")
public class ActivitySummaryController extends BaseController
{
    @Autowired
    private IActivitySummaryService activitySummaryService;

    /**
     * 查询活动纪要列表
     */
    @PreAuthorize("@ss.hasPermi('system:summary:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody ActivityManagement activityManagement)
    {
        setStartPage(activityManagement.getPageNum(),activityManagement.getPageSize());
        List<ActivityManagement> list = activitySummaryService.getActivitySummaryList(activityManagement);
        return getDataTable(list);
    }

    /**
     * 获取活动纪要详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:summary:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activitySummaryService.selectActivitySummaryById(id));
    }

    /**
     * 新增活动纪要
     */
    @PreAuthorize("@ss.hasPermi('system:summary:add')")
    @Log(title = "活动纪要", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivitySummary activitySummary)
    {
        return toAjax(activitySummaryService.insertActivitySummary(activitySummary));
    }

    /**
     * 修改活动纪要
     */
    @PreAuthorize("@ss.hasPermi('system:summary:edit')")
    @Log(title = "活动纪要", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ActivitySummary activitySummary)
    {
        return toAjax(activitySummaryService.updateActivitySummary(activitySummary));
    }

    /**
     * 删除活动纪要
     */
    @PreAuthorize("@ss.hasPermi('system:summary:remove')")
    @Log(title = "活动纪要", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(activitySummaryService.deleteActivitySummaryById(id));
    }
}
